home *** CD-ROM | disk | FTP | other *** search
- incdir "Include:"
- include "exec/types.i"
- include "exec/execbase.i"
- include "exec/tasks.i"
- include "exec/memory.i"
-
-
- include "include/PRIVATE/ASMMacros.i"
- include "include/PRIVATE/patch.i"
- include "include/PRIVATE/patchbase.i"
-
-
- AllocMem set -198
- FreeMem set -210
- Forbid set -132
- Permit set -138
- Disable set -120
- Enable set -126
- FindName set -276
- FindTask set -294
-
- MatchPatternNoCase set -972 ;V37
- MatchPattern set -846 ;V37
- StackSwap set -732 ;V37
-
-
- PatchFreeVec set -84 ;patch
-
- XREF _PatchMatch
-
-
- ;**************************************************
- SECTION code
-
- ; -------------------------------------------------------------------------------
- ;PCODE_START:
- PatchCode6Start:
- dc.l 0
- PatchCode6PatchStruct:
- dc.l 0
- PatchCode6Stack:
- dc.l 0
- dc.l 0
- dc.l 0
- dc.l 0
-
- PC6Offset_Add = *-PatchCode6Start
- addq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
-
- PC6Offset_Stack1_Tst = *-PatchCode6Start
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- beq.s PatchCode6_Stack1_Skip
-
- movem.l d0-d2/a0-a1/a6,-(a7)
- ; movem.l d0-d2/a0-a2/a6,-(a7)
- move.l PatchCode6PatchStruct(pc),a0
- move.l PatchCode6Stack(pc),d0
- jsr PatchLibraryStackAlloc.L ;keeps OMA from optimizing this to bsr
- ; movem.l (a7)+,d0-d2/a0-a2/a6
- movem.l (a7)+,d0-d2/a0-a1/a6
-
- PatchCode6_Stack1_Skip:
- PC6Offset_Sub = *-PatchCode6Start
- subq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC6Offset_JmpNext = *-PatchCode6Start
- jmp $ABABABAB ;$AB just to fool OMA optimizing
-
- PatchCode6End:
- ; -------------------------------------------------------------------------------
- ;PCODE_ORIG
- PatchCode7Start:
- dc.l 0
- dc.l 0
- dc.l 0
- PC7Offset_Disable = *-PatchCode7Start
- dc.l 0
- dc.l 0
- dc.l 0
- PC7Offset_Add = *-PatchCode7Start
- addq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC7Offset_Tst0 = *-PatchCode7Start
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- bne PatchCode7Skip3 ;Disabled ?
-
- PC7Offset_Jsr = *-PatchCode7Start
- jsr $ABABABAB ;$AB just to fool OMA optimizing
-
- PatchCode7Skip3:
- PC7Offset_Sub = *-PatchCode7Start
- subq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC7Offset_JmpNext = *-PatchCode7Start
- jmp $ABABABAB ;$AB just to fool OMA optimizing
- PatchCode7End:
- ; -------------------------------------------------------------------------------
- ;PCODE_GENERIC
- PatchCodeStart:
- PatchCodePatchStruct:
- PC2Offset_PatchXResult = *-PatchCodeStart
- dc.l 0 ;TRUE, if PatchXResult system is used
- PC2Offset_PatchStruct = *-PatchCodeStart
- dc.l 0 ;Pointer to PatchStruct
- PC2Offset_Stack = *-PatchCodeStart
- dc.l 0 ;Stacksize required to execute the patchcode
- PC2Offset_Disable = *-PatchCodeStart
- dc.l 0 ;Disable nesting counter 0= Enabled
- PatchCodeList:
- PC2Offset_List = *-PatchCodeStart
- dc.l 0 ;Exclude/Include List
- PC2Offset_Usage = *-PatchCodeStart
- dc.l 0 ;Usage Counter
- PatchCode:
- PC2Offset_Add = *-PatchCodeStart
- addq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC2Offset_Tst0 = *-PatchCodeStart
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- bne PatchCodeSkip3 ;Disabled ?
-
- PC2Offset_Tst = *-PatchCodeStart
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- beq.s PatchCodeSkip1
-
- movem.l d0/d1/a0/a1,-(sp)
- move.l PatchCodeList(pc),a0
- jsr _PatchMatch.L
- tst.l d0
- movem.l (sp)+,d0/d1/a0/a1
- bne.s PatchCodeSkip2
-
- PatchCodeSkip1:
- move.l #1,-(sp)
-
- PC2Offset_Jsr = *-PatchCodeStart
- jsr $ABABABAB ;$AB just to fool OMA optimizing
- tst.l (a7)+
- PC2Offset_bne = *-PatchCodeStart
- bne.s PatchCodeSkip
-
- addq.l #4,a7
- PC2Offset_Tst1_XResult = *-PatchCodeStart
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- beq.s PatchCode_XResult1_Skip
- jsr PatchLibraryXResult.L ;keeps OMA from optimizing this to bsr
-
-
- PatchCodeSkip2:
- PatchCode_XResult1_Skip:
- PC2Offset_Sub = *-PatchCodeStart
- subq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC2Offset_JmpOrig = *-PatchCodeStart
- jmp $ABABABAB ;$AB just to fool OMA optimizing
-
- PatchCodeSkip:
- PC2Offset_Tst2_XResult = *-PatchCodeStart
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- beq.s PatchCode_XResult2_Skip
- jsr PatchLibraryXResult.L ;keeps OMA from optimizing this to bsr
- bne.s PatchCodeSkip2
-
-
- PatchCode_XResult2_Skip:
- PatchCodeSkip3:
- PC2Offset_Sub2 = *-PatchCodeStart
- subq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC2Offset_SystemEntry = *-PatchCodeStart
- PC2Offset_JmpNext= *-PatchCodeStart
- jmp $ABABABAB ;$AB just to fool OMA optimizing
- PatchCodeEnd:
- ; -------------------------------------------------------------------------------
- ;PCODE_USER0
- PatchCode10Start:
- dc.l 0
- dc.l 0 ;Pointer to PatchStruct
- dc.l 0 ;Stacksize required to execute the patchcode
- dc.l 0 ;Disable nesting counter 0= Enabled
- PatchCode10List:
- dc.l 0 ;Exclude/Include List
- dc.l 0 ;Usage Counter
- PC10Offset_Add = *-PatchCode10Start
- addq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC10Offset_Tst0 = *-PatchCode10Start
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- bne PatchCode10Skip3 ;Disabled ?
-
- PC10Offset_Tst = *-PatchCode10Start
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- beq.s PatchCode10Skip1
-
- movem.l d0/d1/a0/a1,-(sp)
- move.l PatchCode10List(pc),a0
- jsr _PatchMatch.L
- tst.l d0
- movem.l (sp)+,d0/d1/a0/a1
- bne.s PatchCode10Skip2
-
- PatchCode10Skip1:
- move.l #1,-(sp)
-
- PC10Offset_Jsr = *-PatchCode10Start
- jsr $ABABABAB ;$AB just to fool OMA optimizing
- tst.l (a7)+
- bne.s PatchCode10Skip
-
- addq.l #4,a7
-
- PatchCode10Skip2:
- PC10Offset_Sub = *-PatchCode10Start
- subq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC10Offset_JmpOrig = *-PatchCode10Start
- jmp $ABABABAB ;$AB just to fool OMA optimizing
-
- PatchCode10Skip:
- PatchCode10Skip3:
- PC10Offset_Sub2 = *-PatchCode10Start
- subq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC10Offset_JmpNext= *-PatchCode10Start
- jmp $ABABABAB ;$AB just to fool OMA optimizing
- PatchCode10End:
- ; -------------------------------------------------------------------------------
- ;PCODE_USER1
- PatchCode11Start:
- dc.l 0
- dc.l 0 ;Pointer to PatchStruct
- dc.l 0 ;Stacksize required to execute the patchcode
- dc.l 0 ;Disable nesting counter 0= Enabled
- PatchCode11List:
- dc.l 0 ;Exclude/Include List
- dc.l 0 ;Usage Counter
- PC11Offset_Add = *-PatchCode11Start
- addq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC11Offset_Tst0 = *-PatchCode11Start
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- bne PatchCode11Skip3 ;Disabled ?
-
- PC11Offset_Tst = *-PatchCode11Start
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- beq.s PatchCode11Skip1
-
- movem.l d0/d1/a0/a1,-(sp)
- move.l PatchCode11List(pc),a0
- jsr _PatchMatch.L
- tst.l d0
- movem.l (sp)+,d0/d1/a0/a1
- bne.s PatchCode11Skip2
-
- PatchCode11Skip1:
- move.l #1,-(sp)
-
- PC11Offset_Jsr = *-PatchCode11Start
- jsr $ABABABAB ;$AB just to fool OMA optimizing
- tst.l (a7)+
- bne.s PatchCode11Skip
-
- addq.l #4,a7
- jsr PatchLibraryXResult.L ;keeps OMA from optimizing this to bsr
-
-
- PatchCode11Skip2:
- PC11Offset_Sub = *-PatchCode11Start
- subq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC11Offset_JmpOrig = *-PatchCode11Start
- jmp $ABABABAB ;$AB just to fool OMA optimizing
-
-
- PatchCode11Skip:
- jsr PatchLibraryXResult.L ;keeps OMA from optimizing this to bsr
- bne.s PatchCode11Skip2
-
- PatchCode11Skip3:
- PC11Offset_Sub2 = *-PatchCode11Start
- subq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC11Offset_JmpNext= *-PatchCode11Start
- jmp $ABABABAB ;$AB just to fool OMA optimizing
- PatchCode11End:
- ; -------------------------------------------------------------------------------
- ;PCODE_USER2
- PatchCode12Start:
- dc.l 0 ;TRUE, if PatchXResult system is used
- dc.l 0 ;Pointer to PatchStruct
- dc.l 0 ;Stacksize required to execute the patchcode
- dc.l 0 ;Disable nesting counter 0= Enabled
- PatchCode12List:
- dc.l 0 ;Exclude/Include List
- dc.l 0 ;Usage Counter
- PC12Offset_Add = *-PatchCode12Start
- addq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC12Offset_Tst0 = *-PatchCode12Start
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- bne PatchCode12Skip3 ;Disabled ?
-
- PC12Offset_Tst = *-PatchCode12Start
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- beq.s PatchCode12Skip1
-
- movem.l d0/d1/a0/a1,-(sp)
- move.l PatchCode12List(pc),a0
- jsr _PatchMatch.L
- tst.l d0
- movem.l (sp)+,d0/d1/a0/a1
- bne.s PatchCode12Skip2
-
- PatchCode12Skip1:
- PC12Offset_Jsr = *-PatchCode12Start
- jsr $ABABABAB ;$AB just to fool OMA optimizing
-
- PatchCode12Skip2:
- PatchCode12Skip3:
- PC12Offset_Sub2 = *-PatchCode12Start
- subq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC12Offset_JmpNext= *-PatchCode12Start
- jmp $ABABABAB ;$AB just to fool OMA optimizing
- PatchCode12End:
- ; -------------------------------------------------------------------------------
- ;PCODE_USER3
- PatchCode13Start:
- dc.l 0
- dc.l 0 ;Pointer to PatchStruct
- dc.l 0 ;Stacksize required to execute the patchcode
- dc.l 0 ;Disable nesting counter 0= Enabled
- PatchCode13List:
- dc.l 0 ;Exclude/Include List
- dc.l 0 ;Usage Counter
- PC13Offset_Add = *-PatchCode13Start
- addq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC13Offset_Tst0 = *-PatchCode13Start
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- bne PatchCode13Skip3 ;Disabled ?
-
- PC13Offset_Tst = *-PatchCode13Start
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- beq.s PatchCode13Skip1
-
- movem.l d0/d1/a0/a1,-(sp)
- move.l PatchCode13List(pc),a0
- jsr _PatchMatch.L
- tst.l d0
- movem.l (sp)+,d0/d1/a0/a1
- bne.s PatchCode13Skip2
-
- PatchCode13Skip1:
- PC13Offset_Jsr = *-PatchCode13Start
- jsr $ABABABAB ;$AB just to fool OMA optimizing
-
- jsr PatchLibraryXResult.L ;keeps OMA from optimizing this to bsr
-
- PatchCode13Skip2:
- PatchCode13Skip3:
- PC13Offset_Sub2 = *-PatchCode13Start
- subq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC13Offset_JmpNext= *-PatchCode13Start
- jmp $ABABABAB ;$AB just to fool OMA optimizing
- PatchCode13End:
- ; -------------------------------------------------------------------------------
- ;PCODE_USER4 = PCODE_SYSTEM
- PatchCode14Start:
- dc.l 0
- dc.l 0 ;Pointer to PatchStruct
- dc.l 0 ;Stacksize required to execute the patchcode
- dc.l 0 ;Disable nesting counter 0= Enabled
- PatchCode14List:
- dc.l 0 ;Exclude/Include List
- dc.l 0 ;Usage Counter
- PC14Offset_Add = *-PatchCode14Start
- addq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC14Offset_Tst0 = *-PatchCode14Start
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- bne PatchCode14Skip3 ;Disabled ?
-
- PC14Offset_Tst = *-PatchCode14Start
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- beq.s PatchCode14Skip1
-
- movem.l d0/d1/a0/a1,-(sp)
- move.l PatchCode14List(pc),a0
- jsr _PatchMatch.L
- tst.l d0
- movem.l (sp)+,d0/d1/a0/a1
- bne.s PatchCode14Skip3
-
- PatchCode14Skip1:
- PC14Offset_Jsr = *-PatchCode14Start
- jsr $ABABABAB ;$AB just to fool OMA optimizing
-
- PC14Offset_Sub = *-PatchCode14Start
- subq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC14Offset_JmpOrig = *-PatchCode14Start
- jmp $ABABABAB ;$AB just to fool OMA optimizing
-
- PatchCode14Skip3:
- PC14Offset_Sub2 = *-PatchCode14Start
- subq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC14Offset_SystemEntry = *-PatchCode14Start
- PC14Offset_JmpNext= *-PatchCode14Start
- jmp $ABABABAB ;$AB just to fool OMA optimizing
- PatchCode14End:
- ; -------------------------------------------------------------------------------
- ;PCODE_USER5
- PatchCode15Start:
- dc.l 0
- dc.l 0 ;Pointer to PatchStruct
- dc.l 0 ;Stacksize required to execute the patchcode
- dc.l 0 ;Disable nesting counter 0= Enabled
- PatchCode15List:
- dc.l 0 ;Exclude/Include List
- dc.l 0 ;Usage Counter
- PC15Offset_Add = *-PatchCode15Start
- addq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC15Offset_Tst0 = *-PatchCode15Start
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- bne PatchCode15Skip3 ;Disabled ?
-
- PC15Offset_Tst = *-PatchCode15Start
- tst.l $ABABABAB ;$AB just to fool OMA optimizing
- beq.s PatchCode15Skip1
-
- movem.l d0/d1/a0/a1,-(sp)
- move.l PatchCode15List(pc),a0
- jsr _PatchMatch.L
- tst.l d0
- movem.l (sp)+,d0/d1/a0/a1
- bne.s PatchCode15Skip3
-
- PatchCode15Skip1:
- PC15Offset_Jsr = *-PatchCode15Start
- jsr $ABABABAB ;$AB just to fool OMA optimizing
- jsr PatchLibraryXResult.L ;keeps OMA from optimizing this to bsr
-
- PC15Offset_Sub = *-PatchCode15Start
- subq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC15Offset_JmpOrig = *-PatchCode15Start
- jmp $ABABABAB ;$AB just to fool OMA optimizing
-
- PatchCode15Skip3:
- PC15Offset_Sub2 = *-PatchCode15Start
- subq.l #1,$ABABABAB ;$AB just to fool OMA optimizing
- PC15Offset_SystemEntry = *-PatchCode15Start
- PC15Offset_JmpNext= *-PatchCode15Start
- jmp $ABABABAB ;$AB just to fool OMA optimizing
- PatchCode15End:
- ;------------------------------------------------------------------
- XREF _FreeStackCached
- PatchCode8Start:
- dc.l 0
- dc.l 0
- dc.l 0
- dc.l 0
- dc.l 0
- dc.l 0
- cmp.l #'PATC',PST_Magic1(a7)
- bne PatchCode8_Stack3_Skip
-
-
- movem.l d0-d1/a0-a2/a6,-(a7)
- lea.l 4*6(a7),a2 ;4Bytes (6 register)
-
- lea.l PST_Magic1(a2),a0
- cmp.l PST_Magic2(a2),a0
- bne PatchLibraryStackFreeSkip1
-
- move.l a2,a0
- move.l PST_OldStack(a2),a1
- move.l -(a0),-(a1) ;6 registers
- move.l -(a0),-(a1)
- move.l -(a0),-(a1)
- move.l -(a0),-(a1)
- move.l -(a0),-(a1)
- move.l -(a0),-(a1)
-
- move.l sysbase(pc),a6
- lea.l PST_StackSwap(a2),a0
- move.l a1,stk_Pointer(a0)
- CALL StackSwap
-
- move.l a2,a1
- jsr _FreeStackCached
-
- PatchLibraryStackFreeSkip1:
- movem.l (a7)+,d0-d1/a0-a2/a6
-
- PatchCode8_Stack3_Skip:
- tst.l d0
- rts
- PatchCode8End:
- ;----------------------------------------------
- ;PatchLibraryMatch:
- ;a0= Pointer to ListHeader (TaskList)
- ; movem.l d0/d1,-(sp)
- ; jsr _PatchMatch
- ; tst.l d0
- ; movem.l (sp)+,d0/d1
- ; rts
-
-
-
- ; move.l a0,-(sp)
- ;
- ; move.l sysbase(pc),a1
- ; move.l ThisTask(a1),a1
-
- ; move.l (a0),a0
- ; tst.l (a0)
- ; beq PatchLibraryMatchListEmpty
-
- ;PatchLibraryMatchLoop:
- ; cmp.b #TLI_TYPE_TASKID,LN_TYPE(a0)
- ; bne PatchLibraryMatchLoopSkip1
- ; cmp.l LN_NAME(a0),a1
- ; beq PatchLibraryMatchFound
-
- ;PatchLibraryMatchLoopSkip1:
- ; cmp.b #TLI_TYPE_TASKNAME,LN_TYPE(a0)
- ; bne PatchLibraryMatchLoopSkip2
-
- ; movem.l a0/a1,-(sp)
- ; move.l LN_NAME(a0),a0
- ; move.l LN_NAME(a1),a1
-
- ;PatchLibraryMatchLoop2:
- ; cmpm.b (a0)+,(a1)+
- ; bne.s PatchLibraryMatchLoop2Skip
- ; tst.b -1(a0)
- ; bne.s PatchLibraryMatchLoop2
- ; movem.l (sp)+,a0/a1
- ; bra PatchLibraryMatchFound
- ;PatchLibraryMatchLoop2Skip:
- ; movem.l (sp)+,a0/a1
-
- ;PatchLibraryMatchLoopSkip2:
- ; cmp.b #TLI_TYPE_TASKPATTERN,LN_TYPE(a0)
- ; bne PatchLibraryMatchLoopSkip3
-
- ; movem.l d0-d2/a0/a1/a6,-(sp)
- ; move.l LN_SIZE(a0),d1
- ; move.l LN_NAME(a1),d2
- ; move.l patchbase(pc),a6
- ; move.l PB_DosBase(a6),a6
- ; CALL MatchPatternNoCase
- ; tst.l d0
- ; movem.l (sp)+,d0-d2/a0/a1/a6
- ; bne PatchLibraryMatchFound
-
- ;PatchLibraryMatchLoopSkip3:
- ; move.l (a0),a0
- ; tst.l (a0)
- ; bne PatchLibraryMatchLoop
-
- ;PatchLibraryMatchListEmpty:
- ; move.l (sp)+,a0
- ; tst.l TL_Result2(a0)
- ; rts
- ;PatchLibraryMatchFound:
- ; move.l (sp)+,a0
- ; tst.l TL_Result1(a0)
- ; rts
- ;-----------------------------------------------------
- XREF _AllocStackCached
- PatchLibraryStackAlloc:
- ;d0=StackSize
- ;a0=patch struct
-
- move.l d0,d2
- move.l sysbase(pc),a6
- move.l ThisTask(a6),a1
-
- move.l TC_SPLOWER(a1),d0
- move.l TC_SPUPPER(a1),d1
- cmp.l d0,d1
- bhi PatchLibraryStackAllocSkip01
- exg.l d0,d1
-
-
- PatchLibraryStackAllocSkip01:
- cmp.l d0,a7 ;wenn a7 < SPLOWER
- blo PatchLibraryStackAllocExit
-
- cmp.l d1,a7 ;wenn a7 > SPUPPER
- bhi PatchLibraryStackAllocExit
-
- sub.l d0,d1
- CMP.L d2,d1
- BGE PatchLibraryStackAllocExit
-
-
-
- move.l d2,d0
- jsr _AllocStackCached
- tst.l d0
- beq PatchLibraryStackAllocExit
- move.l d0,a1
-
- lea.l 4*7(a7),a0 ;4Bytes * (Rücksprung + 6 register)
- move.l a0,PST_OldStack(a1)
-
- move.l -(a0),-(a1) ;6 registers
- move.l -(a0),-(a1)
- move.l -(a0),-(a1)
- move.l -(a0),-(a1)
- move.l -(a0),-(a1)
- move.l -(a0),-(a1)
- move.l -(a0),-(a1) ;Rücksprung
-
- move.l d0,a0
- move.l a1,PST_StackSwap+stk_Pointer(a0)
- lea.l PST_StackSwap(a0),a0
- jsr StackSwap(a6)
-
- PatchLibraryStackAllocExit:
- rts
- ;-----------------------------------------------------
- PatchLibraryXResult:
- movem.l d0/a1,-(sp)
- tst.l d0
- beq PatchLibraryXResultExit
- move.l d0,a1
- move.l pxr_RegPattern(a1),d0
- asr.l #2,d0
- bcc PatchLibraryXResultSkip1
- move.l pxr_RegA6(a1),a6
-
- PatchLibraryXResultSkip1:
- asr.l #1,d0
- bcc PatchLibraryXResultSkip2
- move.l pxr_RegA5(a1),a5
-
- PatchLibraryXResultSkip2:
- asr.l #1,d0
- bcc PatchLibraryXResultSkip3
- move.l pxr_RegA4(a1),a4
-
- PatchLibraryXResultSkip3:
- asr.l #1,d0
- bcc PatchLibraryXResultSkip4
- move.l pxr_RegA3(a1),a3
-
- PatchLibraryXResultSkip4:
- asr.l #1,d0
- bcc PatchLibraryXResultSkip5
- move.l pxr_RegA2(a1),a2
-
- PatchLibraryXResultSkip5:
- asr.l #1,d0
- bcc PatchLibraryXResultSkip6
- move.l pxr_RegA1(a1),4(a7) ;Nur auf dem stack aendern
-
- PatchLibraryXResultSkip6:
- asr.l #1,d0
- bcc PatchLibraryXResultSkip7
- move.l pxr_RegA0(a1),a0
-
- PatchLibraryXResultSkip7:
- asr.l #1,d0
- bcc PatchLibraryXResultSkip8
- move.l pxr_RegD7(a1),d7
-
- PatchLibraryXResultSkip8:
- asr.l #1,d0
- bcc PatchLibraryXResultSkip9
- move.l pxr_RegD6(a1),d6
-
- PatchLibraryXResultSkip9:
- asr.l #1,d0
- bcc PatchLibraryXResultSkip10
- move.l pxr_RegD5(a1),d5
-
- PatchLibraryXResultSkip10:
- asr.l #1,d0
- bcc PatchLibraryXResultSkip11
- move.l pxr_RegD4(a1),d4
-
- PatchLibraryXResultSkip11:
- asr.l #1,d0
- bcc PatchLibraryXResultSkip12
- move.l pxr_RegD3(a1),d3
-
- PatchLibraryXResultSkip12:
- asr.l #1,d0
- bcc PatchLibraryXResultSkip13
- move.l pxr_RegD2(a1),d2
-
- PatchLibraryXResultSkip13:
- asr.l #1,d0
- bcc PatchLibraryXResultSkip14
- move.l pxr_RegD1(a1),d1
-
- PatchLibraryXResultSkip14:
- asr.l #1,d0
- bcc PatchLibraryXResultSkip15
- move.l pxr_RegD0(a1),(a7) ;Nur auf dem stack aendern
-
- PatchLibraryXResultSkip15:
-
- move.w pxr_FlowControl(a1),d0
-
- movem.l d0-d1/a0/a6,-(sp)
- move.l patchbase(pc),a6
- jsr PatchFreeVec(a6)
- movem.l (sp)+,d0-d1/a0/a6
-
- PatchLibraryXResultExit:
- tst.w d0 ;bits muessen gesetzt sein
- movem.l (sp)+,d0/a1
- rts
- ;-----------------------------------------------------
- ;a0= pointer to patch struct
- ;SUPPORTED PATCHCODES: PCODE_GENERIC, PCODE_START, PCODE_ORIG, PCODE_END
- ; PCODE_USER4
- XDEF _InitPatchCode
- _InitPatchCode:
- move.l a2,-(sp)
- cmp.l #0,a0
- beq InitPatchCodeExit
- tst.l PS_PatchCode(a0)
- beq InitPatchCodeExit
- move.l a0,a2
- move.l PS_PatchCode(a0),a1
-
- InitPatchCodeSkip6:
- cmp.b #PCODE_START,PS_PatchCodeType(a0)
- bne InitPatchCodeSkip7
-
- lea.l PC2Offset_PatchStruct(a1),a0
- move.l a2,(a0)
- lea.l PC2Offset_Stack(a1),a0
- move.l a0,PC6Offset_Stack1_Tst+2(a1)
- lea.l PC2Offset_Usage(a1),a0
- move.l a0,PC6Offset_Add+2(a1)
- move.l a0,PC6Offset_Sub+2(a1)
-
- lea.l PC6Offset_JmpNext(a1),a0
- move.l a0,PS_JmpNext(a2)
-
- lea.l PC6Offset_Add(a1),a0
- move.l a0,PS_TestUsage1(a2)
- lea.l PC6Offset_JmpNext(a1),a0
- move.l a0,PS_TestUsage2(a2)
-
- bra InitPatchCodeExit
-
- InitPatchCodeSkip7:
- cmp.b #PCODE_ORIG,PS_PatchCodeType(a0)
- bne InitPatchCodeSkip8
-
- lea.l PC2Offset_PatchStruct(a1),a0
- move.l a2,(a0)
- lea.l PC2Offset_Disable(a1),a0
- move.l a0,PC7Offset_Tst0+2(a1)
- lea.l PC2Offset_Usage(a1),a0
- move.l a0,PC7Offset_Add+2(a1)
- move.l a0,PC7Offset_Sub+2(a1)
-
- lea.l PC7Offset_Jsr(a1),a0
- move.l a0,PS_Jsr(a2)
- lea.l PC7Offset_JmpNext(a1),a0
- move.l a0,PS_JmpNext(a2)
-
- lea.l PC7Offset_Add(a1),a0
- move.l a0,PS_TestUsage1(a2)
- lea.l PC7Offset_JmpNext(a1),a0
- move.l a0,PS_TestUsage2(a2)
-
- bra InitPatchCodeExit
-
- InitPatchCodeSkip8:
- cmp.b #PCODE_END,PS_PatchCodeType(a0)
- beq InitPatchCodeExit
-
- InitPatchCodeSkip10:
- cmp.b #PCODE_USER0,PS_PatchCodeType(a0)
- bne InitPatchCodeSkip11
-
- lea.l PC2Offset_PatchStruct(a1),a0
- move.l a2,(a0)
- lea.l PC2Offset_Disable(a1),a0
- move.l a0,PC10Offset_Tst0+2(a1)
- lea.l PC2Offset_List(a1),a0
- move.l a0,PC10Offset_Tst+2(a1)
- lea.l PC2Offset_Usage(a1),a0
- move.l a0,PC10Offset_Add+2(a1)
- move.l a0,PC10Offset_Sub+2(a1)
- move.l a0,PC10Offset_Sub2+2(a1)
-
- lea.l PC10Offset_JmpNext(a1),a0
- move.l a0,PS_JmpNext(a2)
- lea.l PC10Offset_JmpOrig(a1),a0
- move.l a0,PS_JmpOrig(a2)
- lea.l PC10Offset_Jsr(a1),a0
- move.l a0,PS_Jsr(a2)
-
- lea.l PC10Offset_Add(a1),a0
- move.l a0,PS_TestUsage1(a2)
- lea.l PC10Offset_JmpOrig(a1),a0
- move.l a0,PS_TestUsage2(a2)
- lea.l PC10Offset_JmpNext(a1),a0
- move.l a0,PS_TestUsage3(a2)
-
- bra InitPatchCodeExit
-
- InitPatchCodeSkip11:
- cmp.b #PCODE_USER1,PS_PatchCodeType(a0)
- bne InitPatchCodeSkip12
-
- lea.l PC2Offset_PatchStruct(a1),a0
- move.l a2,(a0)
- lea.l PC2Offset_Disable(a1),a0
- move.l a0,PC11Offset_Tst0+2(a1)
- lea.l PC2Offset_List(a1),a0
- move.l a0,PC11Offset_Tst+2(a1)
- lea.l PC2Offset_Usage(a1),a0
- move.l a0,PC11Offset_Add+2(a1)
- move.l a0,PC11Offset_Sub+2(a1)
- move.l a0,PC11Offset_Sub2+2(a1)
-
- lea.l PC11Offset_JmpNext(a1),a0
- move.l a0,PS_JmpNext(a2)
- lea.l PC11Offset_JmpOrig(a1),a0
- move.l a0,PS_JmpOrig(a2)
- lea.l PC11Offset_Jsr(a1),a0
- move.l a0,PS_Jsr(a2)
-
- lea.l PC11Offset_Add(a1),a0
- move.l a0,PS_TestUsage1(a2)
- lea.l PC11Offset_JmpOrig(a1),a0
- move.l a0,PS_TestUsage2(a2)
- lea.l PC11Offset_JmpNext(a1),a0
- move.l a0,PS_TestUsage3(a2)
-
- bra InitPatchCodeExit
-
- InitPatchCodeSkip12:
- cmp.b #PCODE_USER2,PS_PatchCodeType(a0)
- bne InitPatchCodeSkip13
-
- lea.l PC2Offset_PatchStruct(a1),a0
- move.l a2,(a0)
- lea.l PC2Offset_Disable(a1),a0
- move.l a0,PC12Offset_Tst0+2(a1)
- lea.l PC2Offset_List(a1),a0
- move.l a0,PC12Offset_Tst+2(a1)
- lea.l PC2Offset_Usage(a1),a0
- move.l a0,PC12Offset_Add+2(a1)
- move.l a0,PC12Offset_Sub2+2(a1)
-
- lea.l PC12Offset_JmpNext(a1),a0
- move.l a0,PS_JmpNext(a2)
- lea.l PC12Offset_Jsr(a1),a0
- move.l a0,PS_Jsr(a2)
-
- lea.l PC12Offset_Add(a1),a0
- move.l a0,PS_TestUsage1(a2)
- lea.l PC12Offset_JmpNext(a1),a0
- move.l a0,PS_TestUsage2(a2)
-
- bra InitPatchCodeExit
-
- InitPatchCodeSkip13:
- cmp.b #PCODE_USER3,PS_PatchCodeType(a0)
- bne InitPatchCodeSkip14
-
- lea.l PC2Offset_PatchStruct(a1),a0
- move.l a2,(a0)
- lea.l PC2Offset_Disable(a1),a0
- move.l a0,PC13Offset_Tst0+2(a1)
- lea.l PC2Offset_List(a1),a0
- move.l a0,PC13Offset_Tst+2(a1)
- lea.l PC2Offset_Usage(a1),a0
- move.l a0,PC13Offset_Add+2(a1)
- move.l a0,PC13Offset_Sub2+2(a1)
-
- lea.l PC13Offset_JmpNext(a1),a0
- move.l a0,PS_JmpNext(a2)
- lea.l PC13Offset_Jsr(a1),a0
- move.l a0,PS_Jsr(a2)
-
- lea.l PC13Offset_Add(a1),a0
- move.l a0,PS_TestUsage1(a2)
- lea.l PC13Offset_JmpNext(a1),a0
- move.l a0,PS_TestUsage2(a2)
-
- bra InitPatchCodeExit
-
- InitPatchCodeSkip14:
- cmp.b #PCODE_USER4,PS_PatchCodeType(a0)
- bne InitPatchCodeSkip15
-
- lea.l PC2Offset_Disable(a1),a0
- move.l a0,PC14Offset_Tst0+2(a1)
- lea.l PC2Offset_List(a1),a0
- move.l a0,PC14Offset_Tst+2(a1)
- lea.l PC2Offset_Usage(a1),a0
- move.l a0,PC14Offset_Add+2(a1)
- move.l a0,PC14Offset_Sub+2(a1)
- move.l a0,PC14Offset_Sub2+2(a1)
-
- lea.l PC14Offset_JmpNext(a1),a0
- move.l a0,PS_JmpNext(a2)
- lea.l PC14Offset_JmpOrig(a1),a0
- move.l a0,PS_JmpOrig(a2)
- lea.l PC14Offset_Jsr(a1),a0
- move.l a0,PS_Jsr(a2)
- lea.l PC14Offset_SystemEntry(a1),a0
- move.l a0,PS_SystemEntry(a2)
-
- lea.l PC14Offset_Add(a1),a0
- move.l a0,PS_TestUsage1(a2)
- lea.l PC14Offset_JmpOrig(a1),a0
- move.l a0,PS_TestUsage2(a2)
- lea.l PC14Offset_JmpNext(a1),a0
- move.l a0,PS_TestUsage3(a2)
-
- bra InitPatchCodeExit
-
- InitPatchCodeSkip15:
- cmp.b #PCODE_USER5,PS_PatchCodeType(a0)
- bne InitPatchCodeSkip16
-
- lea.l PC2Offset_Disable(a1),a0
- move.l a0,PC15Offset_Tst0+2(a1)
- lea.l PC2Offset_List(a1),a0
- move.l a0,PC15Offset_Tst+2(a1)
- lea.l PC2Offset_Usage(a1),a0
- move.l a0,PC15Offset_Add+2(a1)
- move.l a0,PC15Offset_Sub+2(a1)
- move.l a0,PC15Offset_Sub2+2(a1)
-
- lea.l PC15Offset_JmpNext(a1),a0
- move.l a0,PS_JmpNext(a2)
- lea.l PC15Offset_JmpOrig(a1),a0
- move.l a0,PS_JmpOrig(a2)
- lea.l PC15Offset_Jsr(a1),a0
- move.l a0,PS_Jsr(a2)
- lea.l PC15Offset_SystemEntry(a1),a0
- move.l a0,PS_SystemEntry(a2)
-
- lea.l PC15Offset_Add(a1),a0
- move.l a0,PS_TestUsage1(a2)
- lea.l PC15Offset_JmpOrig(a1),a0
- move.l a0,PS_TestUsage2(a2)
- lea.l PC15Offset_JmpNext(a1),a0
- move.l a0,PS_TestUsage3(a2)
-
- bra InitPatchCodeExit
-
-
- InitPatchCodeSkip16:
- ;PCODE_GENERIC is asumed for all unknown PatchCodeTypes
- lea.l PC2Offset_PatchXResult(a1),a0
- move.l a0,PC2Offset_Tst1_XResult+2(a1)
- move.l a0,PC2Offset_Tst2_XResult+2(a1)
- lea.l PC2Offset_PatchStruct(a1),a0
- move.l a2,(a0)
- lea.l PC2Offset_Disable(a1),a0
- move.l a0,PC2Offset_Tst0+2(a1)
- lea.l PC2Offset_List(a1),a0
- move.l a0,PC2Offset_Tst+2(a1)
- lea.l PC2Offset_Usage(a1),a0
- move.l a0,PC2Offset_Add+2(a1)
- move.l a0,PC2Offset_Sub+2(a1)
- move.l a0,PC2Offset_Sub2+2(a1)
-
- lea.l PC2Offset_JmpNext(a1),a0
- move.l a0,PS_JmpNext(a2)
- lea.l PC2Offset_JmpOrig(a1),a0
- move.l a0,PS_JmpOrig(a2)
- lea.l PC2Offset_Jsr(a1),a0
- move.l a0,PS_Jsr(a2)
- lea.l PC2Offset_SystemEntry(a1),a0
- move.l a0,PS_SystemEntry(a2)
-
- lea.l PC2Offset_Add(a1),a0
- move.l a0,PS_TestUsage1(a2)
- lea.l PC2Offset_JmpOrig(a1),a0
- move.l a0,PS_TestUsage2(a2)
- lea.l PC2Offset_JmpNext(a1),a0
- move.l a0,PS_TestUsage3(a2)
-
- InitPatchCodeExit:
- move.l (sp)+,a2
- rts
- ;---------------------------------------------------
- ;a0= pointer to stack
- ;a6= execbase
- ;Result: d0= PC or NULL, if not found
- ;This function is highly dependent on hardware
- ;Keep disabled, or result may not be valid
- XDEF _GetPC
- _GetPC:
- GetPC:
- moveq.l #0,d0
- btst.b #7,AttnFlags+1(a6)
- beq GetPCExit
-
- btst.b #7,AttnFlags+1(a6) ;060 ? OK (currently there is no 060 without FPU)
- beq GetPCSkip1
-
- tst.b 3(a0)
- bne GetPC060Skip
- move.l 12(a0),d0
- bra GetPCExit
- GetPC060Skip:
- move.l 48(a0),d0
- bra GetPCExit
-
- GetPCSkip1:
- btst.b #3,AttnFlags+1(a6) ;040 ?
- beq GetPCSkip2
- moveq.l #0,d0
- bra GetPCExit
-
- GetPCSkip2:
- btst.b #2,AttnFlags+1(a6) ;030 ?
- beq GetPCSkip3
- btst.b #4,AttnFlags+1(a6) ;FPU ?
- beq GetPCSkip2NOFPU
-
- tst.b (a0)
- bne GetPC030Skip1
- move.l 12(a0),d0
- bra GetPCExit
-
- GetPC030Skip1:
- cmp.b #$90,(a0)
- bne GetPC030Skip2
- move.l 120(a0),d0
- bra GetPCExit
-
- GetPC030Skip2:
- move.l 108(a0),d0
- bra GetPCExit
-
-
- GetPCSkip2NOFPU:
- moveq.l #0,d0
- bra GetPCExit
-
- GetPCSkip3:
- btst.b #1,AttnFlags+1(a6) ;020 ? OK
- beq GetPCSkip4
- move.l 2(a0),d0
- bra GetPCExit
-
- GetPCSkip4:
- btst.b #0,AttnFlags+1(a6) ;010 ? OK
- beq GetPCSkip5
- move.l 2(a0),d0
- bra GetPCExit
-
- GetPCSkip5:
- move.l 2(a0),d0
-
- GetPCExit:
- rts
- ;----------------------------------------
- ;a0= patch or NULL for no action
- ;a1= pointer to 8Byte structure or NULL for no action
- ;Result: structure contains size of template in the first 4Bytes
- ; address of template in the second 4Bytes
- ;SUPPORTED PATCHCODES: PCODE_GENERIC, PCODE_START, PCODE_ORIG, PCODE_END
- ; PCODE_USER0 - PCODE_USER5
- XDEF _GetPatchCodeTemplate
- _GetPatchCodeTemplate:
- cmp.l #0,a0
- beq GetPatchCodeTemplateExit
- cmp.l #0,a1
- beq GetPatchCodeTemplateExit
-
- GetPatchCodeTemplateSkip6:
- cmp.b #PCODE_START,PS_PatchCodeType(a0)
- bne GetPatchCodeTemplateSkip7
-
- move.l #PatchCode6End-PatchCode6Start,(a1)+
- lea.l PatchCode6Start(pc),a0
- move.l a0,(a1)+
- bra GetPatchCodeTemplateExit
-
- GetPatchCodeTemplateSkip7:
- cmp.b #PCODE_ORIG,PS_PatchCodeType(a0)
- bne GetPatchCodeTemplateSkip8
-
- move.l #PatchCode7End-PatchCode7Start,(a1)+
- lea.l PatchCode7Start(pc),a0
- move.l a0,(a1)+
- bra GetPatchCodeTemplateExit
-
- GetPatchCodeTemplateSkip8:
- cmp.b #PCODE_END,PS_PatchCodeType(a0)
- bne GetPatchCodeTemplateSkip10
-
- move.l #PatchCode8End-PatchCode8Start,(a1)+
- lea.l PatchCode8Start(pc),a0
- move.l a0,(a1)+
- bra GetPatchCodeTemplateExit
-
- GetPatchCodeTemplateSkip10:
- cmp.b #PCODE_USER0,PS_PatchCodeType(a0)
- bne GetPatchCodeTemplateSkip11
-
- move.l #PatchCode10End-PatchCode10Start,(a1)+
- lea.l PatchCode10Start(pc),a0
- move.l a0,(a1)+
- bra GetPatchCodeTemplateExit
-
- GetPatchCodeTemplateSkip11:
- cmp.b #PCODE_USER1,PS_PatchCodeType(a0)
- bne GetPatchCodeTemplateSkip12
-
- move.l #PatchCode11End-PatchCode11Start,(a1)+
- lea.l PatchCode11Start(pc),a0
- move.l a0,(a1)+
- bra GetPatchCodeTemplateExit
-
- GetPatchCodeTemplateSkip12:
- cmp.b #PCODE_USER2,PS_PatchCodeType(a0)
- bne GetPatchCodeTemplateSkip13
-
- move.l #PatchCode12End-PatchCode12Start,(a1)+
- lea.l PatchCode12Start(pc),a0
- move.l a0,(a1)+
- bra GetPatchCodeTemplateExit
-
- GetPatchCodeTemplateSkip13:
- cmp.b #PCODE_USER3,PS_PatchCodeType(a0)
- bne GetPatchCodeTemplateSkip14
-
- move.l #PatchCode13End-PatchCode13Start,(a1)+
- lea.l PatchCode13Start(pc),a0
- move.l a0,(a1)+
- bra GetPatchCodeTemplateExit
-
- GetPatchCodeTemplateSkip14:
- cmp.b #PCODE_USER4,PS_PatchCodeType(a0)
- bne GetPatchCodeTemplateSkip15
-
- move.l #PatchCode14End-PatchCode14Start,(a1)+
- lea.l PatchCode14Start(pc),a0
- move.l a0,(a1)+
- bra GetPatchCodeTemplateExit
-
-
- GetPatchCodeTemplateSkip15:
- cmp.b #PCODE_USER5,PS_PatchCodeType(a0)
- bne GetPatchCodeTemplateSkip16
-
- move.l #PatchCode15End-PatchCode15Start,(a1)+
- lea.l PatchCode15Start(pc),a0
- move.l a0,(a1)+
- bra GetPatchCodeTemplateExit
-
- GetPatchCodeTemplateSkip16:
-
- ;PCODE_GENERIC is asumed for all unknown PatchCodeTypes
- move.l #PatchCodeEnd-PatchCodeStart,(a1)+
- lea.l PatchCodeStart(pc),a0
- move.l a0,(a1)+
-
-
- GetPatchCodeTemplateExit:
- rts
- ;-----------------------------------------------------------------
- XDEF _SetupAsmEnv
- ; a0 = pointer to patchbase
- _SetupAsmEnv:
- lea.l patchbase(pc),a1
- move.l a0,(a1)
- lea.l sysbase(pc),a1
- move.l PB_SysBase(a0),(a1)
- rts
- patchbase: dc.l 0
- sysbase: dc.l 0
- END
-